package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.UpdateOrderBean;
import com.xuxin.baby.contract.OrderCommitContract;
import com.xuxin.baby.model.OrderCommitModel;

import okhttp3.RequestBody;

/**
 * Created by xu_xin
 * Created on 2020/10/23 0023
 * 提交订单
 */
public class OrderCommitPresenter implements OrderCommitContract.Presenter {
    private final OrderCommitModel model;
    private  final OrderCommitContract.View view;

    public OrderCommitPresenter(OrderCommitContract.View view) {
        this.view = view;
        model = new OrderCommitModel();
    }

    @Override
    public void updateOrder(String tenantId, String token, String memberId, RequestBody requestBody) {
        if (null != model) {
            model.updateOrder(this, tenantId, token, memberId, requestBody);
        }
    }

    @Override
    public void updateOrderStatus(String tenantId, String token, String orderId, String status,String paymentMtd,String tradeType) {
        if (null != model) {
            model.updateOrderStatus(this, tenantId, token, orderId, status,  paymentMtd,tradeType);
        }
    }

    @Override
    public void onSuccess(UpdateOrderBean updateOrderBean) {
        if (null != view) {
            view.onSuccess(updateOrderBean);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}